//
//  BillDetailsView.swift
//  KaMengApplication
//
//  Created by DUONIU_MAC on 2018/11/26.
//  Copyright © 2018年 DUONIU_MAC. All rights reserved.
//

import UIKit

class BillDetailsView: UIView {

    fileprivate let billDateLabel = UILabel() //出账日
    fileprivate let freeDateLabel = UILabel() //免息期
    
    init(model:InputBillModel) {
        super.init(frame: .zero)
        
        billDateLabel.backgroundColor = UIColor.white
        billDateLabel.text = billingDate + "：" + model.billDate!
        billDateLabel.textColor = UIColor.gray
        billDateLabel.textAlignment = .center
        billDateLabel.font = UIFont.systemFont(ofSize: RATIO(maxNum: 16))
        self.addSubview(billDateLabel)
        
        //免息期计算
        let dayNumber = (Double((model.repaymentDate?.getTimestamp())!) - Double((model.billDate?.getTimestamp())!))/(24*3600)
        
        freeDateLabel.backgroundColor = UIColor.white
        freeDateLabel.text = freeDate + "：" + "\(Int(dayNumber))" + days
        freeDateLabel.textColor = UIColor.gray
        freeDateLabel.textAlignment = .center
        freeDateLabel.font = UIFont.systemFont(ofSize: RATIO(maxNum: 16))
        self.addSubview(freeDateLabel)
        
        billDateLabel.snp.makeConstraints { (make) in
            make.left.centerY.height.equalToSuperview()
            make.width.equalTo(ScreenW/2-0.5)
        }
        
        freeDateLabel.snp.makeConstraints { (make) in
            make.right.centerY.height.equalToSuperview()
            make.width.equalTo(billDateLabel)
        }
        
        
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    

}
